package com.wyg.blog.controller.manage_blog;

import com.wyg.blog.service.blog.UploadPictureService;
import com.wyg.blog.utils.JsonResult;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;

import java.io.IOException;

/**
 * @description:
 * @author: WYG
 * @time: 2020/7/2 16:23
 */
@RestController
@RequestMapping("/api/upload")
public class UploadController {
    @Autowired
    private UploadPictureService uploadPictureService;

    @PostMapping("/picture")
    @CrossOrigin
    public JsonResult<String> uploadPicture(@RequestParam("file") MultipartFile multipartFile) throws IOException {
        String pictureUrl = uploadPictureService.uploadPicture(multipartFile);
        return new JsonResult<String>(pictureUrl,"200","上传成功!");
    }
}
